import 'package:flutter/material.dart';
import 'package:video_demo/view/video_view.dart';

class VideoPage extends StatefulWidget {
  @override
  _VideoPageState createState() => _VideoPageState();
}

class _VideoPageState extends State<VideoPage> {
  //定义按钮集合
  List bottonList;
  //根据按钮集合数据构建操控按钮
  List<Widget> _buildButton() {
    var list = bottonList.map((obj) {
      return Container(
        margin: EdgeInsets.symmetric(horizontal: 5),
        child: MaterialButton(
          color: Colors.blue,
          textColor: Colors.white,
          onPressed: () {},
          child: Text(obj["title"]),
        ),
      );
    });
    return list.toList();
  }

  @override
  void initState() {
    super.initState();
    //初始化按钮集合数据
    bottonList = [
      {
        "title": "向上",
        "predict": 1,
      },
      {
        "title": "向下",
        "predict": 2,
      },
      {
        "title": "向左",
        "predict": 3,
      },
      {
        "title": "向右",
        "predict": 4,
      },
    ];
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('视频监控'),
      ),
      body: Column(
        children: <Widget>[
          AspectRatio(
            child: VideoView(),
            aspectRatio: 1280 / 1100,
          ),
          Row(
            children: this._buildButton(),
          ),
        ],
      ),
    );
  }
}
